import pymysql

conn = pymysql.connect(host='192.168.196.128', db='wa_test', user='root', passwd='123456')
cursor = conn.cursor()
sqls = ["delete from info where id=(select id from users where username='test06')",
        "delete from users where username='test06'"]
for sql in sqls:
    cursor.execute(sql)
conn.commit()
conn.close()

import requests

url = 'http://192.168.196.128/apitest/login/'
args = {'username': 'test01', 'password': '123456'}
res = requests.post(url, args)
print(res.text)
# 使用==对比响应结果，如果响应结果是json类型，建议用==
actual = res.json()
expect = {'Status': 1000, 'Result': 'Usercheck ok', 'Message': '登录验证成功'}
# 用==时，预期结果写成字典
if expect == actual:
    # 实际结果用的json,用==比较
    print('响应结果对比成功')
else:
    print(f'响应结果对比失败==预期：{expect}==实际：{actual}')

conn = pymysql.connect(host='192.168.196.128', db='wa_test', user='root', passwd='123456')
cursor = conn.cursor()
sql = "select count(*) from users,info where users.id=info.id and username='test06' and password=md5('123456') and info.name='测试六';"
cursor.execute(sql)
row = cursor.fetchone()
actual_rows = row[0]
expect_rows = 1
if expect_rows == actual_rows:
    print('验证通过')
else:
    print(f'验库失败==要检查的数据；{args}==预期行数:{expect_rows}==实际行数：{actual_rows}')
conn.close()
